<%@ page language="java" import="java.util.*" pageEncoding="Utf-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>订单列表</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/common/style/qdh.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/common/style/member.css" type="text/css" media="screen" />
<script type="text/javascript" src="${pageContext.request.contextPath}/common/js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/common/js/common.js"></script>
<SCRIPT type="text/javascript">
function checkReview(id){
	$.getJSON('checkReview.action',{id:id},function(data){
			if(data.success){
				window.open("quick_review.jsp?id="+id);
			}
			else{
			$(".order-error").hide();
			$(".review-error").slideDown();
			setTimeout(function(){$(".review-error").slideUp();},2000)
			}
	})	
}
function checkOrder(id){
	$.getJSON('checkOrder.action',{id:id},function(data){
		if(data.success){
			window.open("orderDetail.action?id="+id);
		}
		else{
		$(".review-error").hide();
		$(".order-error").slideDown();
		setTimeout(function(){$(".order-error").slideUp();},2000)
		}
	})
}
</SCRIPT>
</head>
<body>
<div id="wrap">
	<div class="order-error">您已付款，无需重复付款</div>
	<div class="review-error">您已点评，请勿重复点评</div>
	<s:include value="header.jsp"/>	
	<div id="container">
		<div class="fl membersiderbox">
			<h1>用户中心</h1>
			<div class="mleft">
				<s:include value="mleft.jsp"/>
			</div>
		</div>
		<div class="fr membermain">
			<div class="mright1">
				<div class="orderinfobox">
					<div class="orderinfotabshow">
						<div>
							<table width="100%" cellspacing="0" cellpadding="0">
							    <thead>
								    <tr>
										<td width="150">订单号</td>														
										<td>入住时间</td>
										<td>总金额</td>
										<td>订单状态</td>						
										<td>操作</td>										
									</tr>
								</thead>
								<tbody>
									<s:iterator value="orderlist" id="x">
									    <tr>
									    	<td><a href="orderDetail.action?id=${x.id}" target="_blank">${x.code}</a></td>
										    <td><s:date name="#x.checkinTime" format="yyyy-MM-dd"/></td>
										    <td>${x.totalMoney}</td>
										    <td>
										   <s:if test="#x.verify==1">
										    <s:if test="#x.tradeStatus==1">
													<font color="red">未付款[<a  href="javascript:;"  onclick=" checkOrder(${x.id});">去付款</a>]</font>
											</s:if>
											<s:if test="#x.tradeStatus==2">
													<font color="green">已付款</font>
											</s:if>
											<s:if test="#x.tradeStatus==3">
													<font color="green">已入住</font>
											</s:if>
											<s:if test="#x.tradeStatus==4">
													<font color="green">已结束</font>
													<s:if test="#x.isReview==0">
													[<a href="javascript:;"  onclick=" checkReview(${x.id});">去点评</a>]
													</s:if>
													<s:else>
													[已点评]
													</s:else>
											</s:if>
											<s:if test="#x.tradeStatus==5">
													<font color="green">已取消</font>
											</s:if>
										</s:if>
										<s:else>
											<s:if test="#x.tradeStatus==5">
													<font color="green">已取消</font>
											</s:if>
											<s:else>
													<font color="red">待审核</font>
											</s:else>
										</s:else>
											</td>					    
										    <td><a href="orderDetail.action?id=${x.id}" target="_blank">查看</a>
										    <s:if test="#x.tradeStatus!=5&&#x.verify==0">
										    
										    <a href="javascript:;" onclick="cancel(${x.id});" >取消</a>
										    
										    </s:if>
										    </td>
										    <script>
											function cancel(id){
											if(confirm("确定取消订单吗")){
												$.ajax({
													dataType:'json',
													type:'post',
													url:'cancelOrder.action',
													data:'id='+id,
													success:function(data){
														if(data.success){
															alert("成功");
															location=location;
														}
														}																																							
												});
												}else return false;
											}
											
										    </script>
										</tr>
									</s:iterator>
								</tbody>
							</table>
							<div>				
							</div>	
						</div>
					</div>
				</div>				
			</div>
		</div>
		<div class="clr"></div>   
		<div class="fr listpage">${pagination}</div>   
	</div>
    <div class="mt15"></div>
	<s:include value="../footer.htm"/>

</div>
</body>
</html>
